#include <iostream>
#include <vector>

int diagonalSum(std::vector<std::vector<int>>& mat) {
    int sum = 0;
    int n = mat.size();
    for (int i = 0; i < n; i++) {
        sum += mat[i][i]; 
        sum += mat[i][n - 1 - i]; 
    }
    if (n % 2 == 1) {
        sum -= mat[n / 2][n / 2];
    }
    return sum;
}

int main() {
    std::vector<std::vector<int>> mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    int sum = diagonalSum(mat);
    std::cout << "The sum of the diagonal elements is: " << sum << std::endl;
    return 0;
}
